package demo1;

class Animal{
    public String name;
    public int age;

    public Animal(String name){
        this.name = name;
    }
}

interface IRunning{
    void Running();
}
interface ISwimming{
    void Swimming();
}

class Dog extends Animal implements IRunning, ISwimming {
    public Dog(String name){
        super(name);
    }
    @Override
    public void Running(){
        System.out.println(this.name + "正在跑!");
    }
    @Override
    public void Swimming(){
        System.out.println(this.name + "正在狗刨!");
    }
}
class Cat extends Animal implements IRunning {
    public Cat(String name){
        super(name);
    }
    @Override
    public void Running(){
        System.out.println(this.name + "正在跑!");
    }
}
class Fish extends Animal implements ISwimming {
    public Fish(String name){
        super(name);
    }
    @Override
    public void Swimming(){
        System.out.println(this.name + "正在游!");
    }
}

/*class Dog extends Animal{
    public Dog(String name){
        super(name);
    }
    public void Running(){
        System.out.println(this.name + "正在跑!");
    }
    public void Swimming(){
        System.out.println(this.name + "正在狗刨!");
    }
}
class Cat extends Animal{
    public Cat(String name){
        super(name);
    }
    public void Running(){
        System.out.println(this.name + "正在跑!");
    }
}
class Fish extends Animal{
    public Fish(String name){
        super(name);
    }
    public void Swiming(){
        System.out.println(this.name + "正在游!");
    }
}*/

public class TestDemo {

    //只要实现了该接口的类，都可以传入
    public static void walk(IRunning iRunning) {
        iRunning.Running();
    }

    public static void main(String[] args) {
        walk(new Dog("yuan"));
        walk(new Dog("bao"));
        walk(new Cat("wert"));
    }
}